<template>
  <div>
    <div class="wrapper">
      <Anchor :labelList="labels" :labelWidth="85">
        <div id="row-01" class="line">
          <BreakSpace label="派工单信息" :containerStyle="{ marginBottom: '10px' }"></BreakSpace>
          <FormPanel ref="formPanel" :list="formList" labelWidth="130" :cols="3" :formType="type" :isSubmitBtn="false" @formChange="formChangeHandle" />
        </div>
        <div id="row-02" class="line">
          <BreakSpace label="装饰项目" :containerStyle="{ marginBottom: '10px' }"></BreakSpace>
          <FilterTable
            ref="tableProject"
            height="auto"
            columnsRef="zsxmpgd"
            :columns="columnsWts"
            :dataSource="listProduct"
            selectionType="multiple"
            :onRowSelectChange="handleProjectTableSelectChange"
            :onColumnsChange="columns => (this.columnsWts = columns)"
          >
            <template slot="moreActions">
              <span @click="handleProjectDeleteRowData">删除数据</span>
            </template>
            <template v-if="type !== 'show'" slot="controls">
              <el-button type="primary" @click="addHandle">新增</el-button>
            </template>
          </FilterTable>
        </div>
        <div id="row-03" class="line">
          <BreakSpace label="装饰材料" :containerStyle="{ marginBottom: '10px' }"></BreakSpace>
          <FilterTable
            ref="table1"
            columnsRef="zsxmcl"
            height="auto"
            :columns="columnDialogColumns"
            :dataSource="listWts"
            :onCellChange="tableCellChange"
            :onSyncTableData="tableHandle"
            selectionType="multiple"
            :onRowSelectChange="handlePartTableSelectChange"
            :onColumnsChange="columns => (this.columnDialogColumns = columns)"
          >
            <template slot="moreActions">
              <span @click="handlePartDeleteRowData">删除数据</span>
            </template>
            <template v-if="type !== 'show'" slot="controls">
              <el-button type="primary" @click="addMaterialHandle">新增</el-button>
            </template>
          </FilterTable>
        </div>
      </Anchor>
    </div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeHandler">关闭</el-button>
      <AjaxButton :click="saveHandler" type="primary">保存</AjaxButton>
    </div>

    <!-- 新增选择装饰项目 -->
    <BaseDialog :visible.sync="visibleProduct" title="选择装饰项目" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <productSelection type="edit" :modifyType="modifyType" :rowData="formData" @close="closeHandler22" @close3="closeHandlerProduct" @onConfirm="handleProjectConfirm" />
    </BaseDialog>
    <!-- 新增选择装饰材料 -->
    <BaseDialog :visible.sync="visibleMaterial" title="选择装饰材料" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <materialSelection type="edit" :modifyType="modifyType" :rowData="formData" @close="visibleMaterial = false" @onConfirm="handleDecorateConfirm" />
    </BaseDialog>
    <!-- 客户代码弹窗 -->
    <!-- <BaseDialog :visible.sync="visibleCustomer" title="客户代码" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }"> -->
    <!-- <customer type="edit" :modifyType="modifyType" :rowData="formData" @saveDialog="handleDealerSelectConfirm" @close2="closeHandlerCustomer1" /> -->
    <!-- <vehicleOwner type="edit" @saveDialog="handleDealerSelectConfirm" @close="visibleCustomer = false" />
    </BaseDialog> -->
    <!-- 底盘号弹窗 -->
    <BaseDialog :visible.sync="visibleVinSelect" title="底盘号" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <vinSelect type="edit" :modifyType="modifyType" :rowData="formData" @onConfirm="handleVinSelectConfirm" @close2="closeHandlervin" />
    </BaseDialog>
    <!-- 会员卡号 -->
    <BaseDialog :visible.sync="visibleCardHandleSelect" title="会员卡号" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <cardHandle type="edit" :modifyType="modifyType" :rowData="formData" @onConfirm="handleCardSelectConfirm" @close2="closeHandlerCard" />
    </BaseDialog>
    <!-- 对应整车销售单号选择弹窗 -->
    <BaseDialog :visible.sync="carSaleOrderVisible" title="整车销售单" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <carSaleOrderSelect @close="carSaleOrderVisible = false" @onConfirm="handleCarOrderSelectConfirm"></carSaleOrderSelect>
    </BaseDialog>
    <!-- 供应商选择弹窗 -->
    <BaseDialog title="选择供应商" :visible.sync="supplierVisible" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <provideSearchHelper @onConfirm="handlePositionSelectConfirm" @close="supplierVisible = false" />
    </BaseDialog>
  </div>
</template>

<script>
// 数据字典/按钮权限
import { dictionary } from '@/utils/dictMixin';
import { authority } from '@/utils/authMixin';
import { notifyAction } from '@/utils';
import { jsonToHump } from '@/utils/index';
import productSelection from './decorProductSeletion';
import materialSelection from './decorMaterialSeletion';
import customer from './customer';
import vinSelect from './vinSelect';
import cardHandle from './cardHandle';
import carSaleOrderSelect from './carSaleOrderSelect';
import { excutePartOrderInfo, getProjectList, getMaterialList, getOrderNo, getRate, getCardHandle } from '@/api/part/qualityManagement/decorationDispatchOrder';
import { getStorageList } from '@/api/part/common';
import moment from 'moment';
import vehicleOwner from '@/pages/part/partOutbound/partSales/vehicleOwner';
import { queryTex } from '@/api/part/common';
// import { queryBusinessCustomer } from '@/api/part/partInfoManage/contactsCustomer';
import provideSearchHelper from '@/pages/part/partPurchase/purchaseOrder/provideSearchHelper';

export default {
  name: '',
  components: {
    productSelection,
    materialSelection,
    customer,
    vinSelect,
    cardHandle,
    carSaleOrderSelect,
    vehicleOwner,
    provideSearchHelper
  },
  mixins: [dictionary, authority],
  props: {
    type: {
      type: String
    },
    formData: {
      type: Object,
      default: () => ({})
    },
    rowData: {
      type: Object,
      default: () => ({})
    },
    baseData: {
      // 客户订单功能页面过来的才有add/edit/show
      type: Array,
      default: () => []
    }
  },

  data() {
    this.saveData = null;
    this.rate = null;
    return {
      labels: this.createAnchorLabels(),
      visibleProduct: false, // 选择产品
      // visibleCustomer: false,
      visibleVinSelect: false,
      visibleCardHandleSelect: false,
      visible5: false,
      // formData: {},
      isChoice: true, // 选中数据false，未选中数据true
      modifyType: true, // 该页面默认为修改
      selectCustomerId: '', // 当前所选customerId
      formList: this.createFormList(),
      serviceItem: this.serviceSource,
      serviceSource: [], // 默认的赋值
      visibleService: false, // 新增服务项目
      visibleMaterial: false,
      columnsWts: this.createTableColums(),
      columnDialogColumns: this.createDialogColumns(),
      listWts: [],
      listProduct: [],
      selectedProjectTableData: [], // 选中的项目列表
      selectedPartTableData: [], // 选中的装饰件列表
      carSaleOrderVisible: false, // 是否显示选择整车订单弹窗
      tex: 0, // 税率
      supplierVisible: false,
      dindex: null
    };
  },
  mounted() {
    // 初始化方法
    this.initialHandle();
    this.queryTex();
    this.createBaseTable();
    this.getOrderNo();
    this.getRate();
    this.getCardHandle();
    this.queryStorageInfo(); // 查询所有仓库
  },
  methods: {
    initialHandle() {
      if (this.type === 'edit') {
        this.formList.forEach(x => {
          const val = this.formData[x.fieldName];
          if (typeof val === 'undefined') return;
          x.initialValue = val;
        });
        // 获取装饰项目数据
        this.getProductList(this.formData.id);
        // 获取装饰材料数据
        this.getMaterialList(this.formData.id);
      }
    },
    async getCardHandle() {},
    createAnchorLabels() {
      return [
        {
          title: '派工单信息',
          id: 'row-01'
        },
        {
          title: '装饰项目',
          id: 'row-02'
        },
        {
          title: '装饰材料',
          id: 'row-03'
        }
      ];
    },
    createFormList() {
      return [
        {
          type: 'INPUT',
          label: '对应整车销售单号',
          fieldName: 'saleOrderNo',
          placeholder: '请输入...',
          disabled: false,
          unitRender: props => {
            return <el-button icon="el-icon-search" onClick={() => (this.carSaleOrderVisible = true)}></el-button>;
          }
        },
        {
          type: 'INPUT',
          label: '底盘号',
          fieldName: 'vin',
          placeholder: '请输入...',
          disabled: false,
          readonly: true,
          rules: [{ required: true, message: '请选择底盘号', trigger: 'blur' }],
          unitRender: props => {
            return <el-button icon="el-icon-search" onClick={() => this.searchVinSelect()}></el-button>;
          }
        },
        {
          type: 'INPUT',
          label: '牌照号',
          fieldName: 'licenseTag',
          placeholder: '请输入...',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '会员卡号',
          fieldName: 'cardNo',
          readonly: true,
          placeholder: '请输入...',
          disabled: false,
          unitRender: props => {
            return <el-button icon="el-icon-search" onClick={() => this.serchCardSelect()}></el-button>;
          }
        },
        {
          type: 'INPUT',
          label: '客户代码',
          fieldName: 'customerNo',
          placeholder: '请选择',
          // rules: [{ required: true, message: '请选择客户代码', trigger: 'blur' }],
          disabled: true
          // readonly: true,
          // unitRender: props => {
          //   return <el-button icon="el-icon-search" onClick={() => this.searchCustomer()}></el-button>;
          // }
        },
        {
          type: 'INPUT',
          label: '客户名称',
          fieldName: 'customerName',
          placeholder: '请输入...',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '装饰派工单号',
          fieldName: 'billNo',
          disabled: true
        },
        {
          type: 'SELECT',
          label: '工单状态',
          fieldName: 'roStatus',
          placeholder: '请选择',
          itemList: this.createDictList('9704'),
          initialValue: 97041001,
          disabled: true
          // rules: [{ required: true, message: '请选择工单状态', trigger: 'change' }]
        },

        {
          type: 'DATE',
          label: '派工日期',
          fieldName: 'orderDate',
          initialValue: moment().format('YYYY-MM-DD'),
          disabled: false
        },
        {
          type: 'INPUT',
          label: '车型代码',
          fieldName: 'model',
          placeholder: '请输入...',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '操作员',
          fieldName: 'whManagerId',
          placeholder: '请输入...',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '备注',
          fieldName: 'remarks',
          placeholder: '请输入...',
          disabled: false
        }
      ];
    },
    createTableColums() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.$index + 1}</span>;
          }
        },
        {
          title: '装饰项目代码',
          dataIndex: 'proCode',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '装饰项目名称',
          dataIndex: 'proName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '装饰项目工时费',
          dataIndex: 'manhaurFee',
          minWidth: 250,
          sorter: true,
          filter: true,
          filterType: 'number',
          precision: 2
        },
        {
          title: '班组',
          dataIndex: 'bzCode',
          minWidth: 100,
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '班组名称',
          dataIndex: 'bzName',
          minWidth: 250,
          filter: true,
          filterType: 'input'
        }
      ];
    },
    createDialogColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.$index + 1}</span>;
          }
        },

        {
          title: '仓库名称',
          dataIndex: 'storageCode',
          sorter: true,
          filter: true,
          dictItems: [],
          filterType: 'input'
        },
        {
          title: '出库状态',
          dataIndex: 'status',
          filter: true,
          filterType: 'radio',
          filterItems: [
            { text: '未出库', value: '97071001' },
            { text: '已出库', value: '97071002' }
          ],
          editable: false,
          editType: 'select',
          editItems: this.createDictList('9707')
        },
        {
          title: '出库方式',
          dataIndex: 'outType',
          sorter: true,
          filter: true,
          placeholder: '请选择',
          filterType: 'radio',
          filterItems: [
            { text: '正常销售', value: '80961001' },
            { text: '一进一出', value: '80961002' }
          ],
          editRequired: true,
          defaultEditable: true,
          editable: true,
          editType: 'select',
          editItems: this.createDictList('8096')
        },
        {
          title: '装饰件代码',
          dataIndex: 'partNo',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '装饰件名称',
          dataIndex: 'partName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '数量',
          dataIndex: 'partQty',
          precision: 2,
          minWidth: 100,
          summation: true,
          editable: true,
          defaultEditable: true,
          editRequired: true,
          min: 0,
          editType: 'number',
          filter: true,
          filterType: 'number'
          // editDisableRender: params => {
          //   return <el-input value={params.row.partQty}></el-input>;
          // }
        },
        {
          title: '含税出库单价',
          dataIndex: 'costOutPrice',
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },

        {
          title: '含税销售单价',
          dataIndex: 'costSalesPrice',
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '出库数量',
          dataIndex: 'outQuantity',
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number'
        },
        {
          title: '出库金额',
          dataIndex: 'dfs',
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number',
          summation: true,
          editType: 'number',
          render: props => {
            props.row.dfs = (Number(props.row.partQty) * Number(props.row.costOutPrice)).toFixed(2);
            return <span>{props.row.dfs}</span>;
          }
        },
        {
          title: '供应商名称',
          dataIndex: 'providerName',
          sorter: true,
          filter: true,
          filterType: 'input',
          render: params => {
            return (
              <el-input disabled={params.row.outType != 80961002} placeholder="请选择..." value={params.row.providerName} readonly size="mini">
                <el-button
                  slot="append"
                  icon="el-icon-search"
                  onClick={() => {
                    this.handleChosePosition(params.$index);
                  }}
                ></el-button>
              </el-input>
            );
          }
        },
        {
          title: '含税采购单价',
          dataIndex: 'planPrice',
          editable: true,
          editType: 'number',
          defaultEditable: true,
          editRequired: true,
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number',
          render: props => {
            props.row.planPrice = (Number(props.row.planPrice1) * this.tex + Number(props.row.planPrice1)).toFixed(2);
            return <span>{props.row.planPrice}</span>;
          }
        },
        {
          title: '采购税额',
          dataIndex: 'planRatePrice',
          precision: 2,
          sorter: true,
          filter: true,
          filterType: 'number',
          render: props => {
            props.row.planRatePrice = ((Number(props.row.planPrice) / (1 + Number(this.tex))) * Number(this.tex) * Number(props.row.partQty)).toFixed(2);
            return <span>{props.row.planRatePrice}</span>;
          }
        },
        {
          title: '含税采购金额',
          dataIndex: 'butMoney',
          precision: 2,
          summation: true,
          sorter: true,
          filter: true,
          filterType: 'number',
          render: props => {
            props.row.butMoney = (Number(props.row.planPrice) * Number(props.row.partQty)).toFixed(2);
            return <span>{props.row.butMoney}</span>;
          }
        },
        {
          title: '保质期标识',
          dataIndex: 'shelfLiftMark',
          editable: true,
          editType: 'checkbox',
          editItems: [
            { text: '', trueValue: '1' },
            { text: '', falseValue: '0' }
          ],
          disabled: true,
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [
            { text: '是', trueValue: '1' },
            { text: '否', falseValue: '0' }
          ]
        },
        {
          title: '库位',
          dataIndex: 'storagePositionCode',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
      ];
    },
    handleChosePosition(val) {
      this.dindex = val;
      this.supplierVisible = true;
    },
    handlePositionSelectConfirm(val) {
      console.log(val, '供应商带回');
      this.listWts[this.dindex].providerName = val.customerName;
    },
    tableHandle(val) {
      for (const item of val) {
        if (item.outType == 80961002) {
          this.BaseTable1.SET_CELL_DISABLED(item, 'planPrice', false);
          this.BaseTable1.SET_CELL_DISABLED(item, 'providerName', true);
        } else {
          this.BaseTable1.SET_CELL_DISABLED(item, 'planPrice', true);
          this.BaseTable1.SET_CELL_DISABLED(item, 'providerName', false);
        }
      }
    },
    addHandle() {
      console.log('新增装饰项目');
      this.visibleProduct = true;
    },
    addMaterialHandle() {
      console.log('新增装饰材料项目', 'lt');
      this.visibleMaterial = true;
    },
    // 查询所有仓库
    async queryStorageInfo() {
      let res = await getStorageList();
      if (res.resultCode == 200) {
        this.columnDialogColumns.find(item => item.dataIndex == 'storageCode').dictItems = res.data.map(item => ({ text: item.STORAGE_NAME, value: item.STORAGE_CODE }));
      }
    },
    async queryTex() {
      let res = await queryTex();
      if (res.resultCode == 200) {
        this.tex = Number(res.data);
      }
    },
    // 声明表格组件
    createBaseTable() {
      this.BaseTable1 = this.$refs.table1.$refs.pageTable;
      this.tableProject1 = this.$refs.tableProject.$refs.pageTable;
    },
    // table行项输入改变
    tableCellChange(e) {
      // console.log(e);
      // this.reCalculateTableData();
    },
    // 计算装饰材料各字段
    // reCalculateTableData() {
    //   this.listWts.map(item => {
    //     console.log('进来了' + item.partQty);
    //     item.dfs = item.partQty * item.costSalesPrice;
    //     item.butMoney = item.partQty * item.planPrice;
    //     item.planRatePrice = item.butMoney * this.rate;
    //   });
    // },
    async getRate() {
      this.rateData = (await getRate({})).data;
      this.rate = this.rateData.rate;
    },
    // searchCustomer() {
    //   this.visibleCustomer = true;
    // },
    searchVinSelect() {
      this.visibleVinSelect = true;
    },
    serchCardSelect() {
      this.visibleCardHandleSelect = true;
    },
    // 装饰材料点击新增
    handleDecorateConfirm(data) {
      console.log(data, '装饰材料返回');
      for (const item of data) {
        item.status = 97071001;
        item.outType = 80961001;
      }
      this.$refs.table1.$refs.pageTable.EXECUTE_INSERT(data);
    },
    // 删除项目数据
    handleProjectDeleteRowData() {
      if (!this.selectedProjectTableData.length) return;
      this.$refs.tableProject.EXECUTE_DELETE(this.selectedProjectTableData);
    },
    // table行项选中变化
    handleProjectTableSelectChange(e) {
      this.selectedProjectTableData = e;
    }, // 删除材料数据
    handlePartDeleteRowData() {
      if (!this.selectedPartTableData.length) return;
      this.$refs.table1.EXECUTE_DELETE(this.selectedPartTableData);
    },
    // table行项选中变化
    handlePartTableSelectChange(e) {
      this.selectedPartTableData = e;
    },
    closeHandlervin() {
      this.visibleVinSelect = false;
    },
    closeHandlerCard() {
      this.visibleCardHandleSelect = false;
    },

    closeHandlerProduct(val, data) {
      this.visibleProduct = val;
      this.$refs.tableProject.$refs.pageTable.EXECUTE_INSERT(data);
    },
    closeHandler22(val) {
      this.visibleProduct = val;
    },
    // handleDealerSelectConfirm(val) {
    //   // console.log(val, '选择经销商点击确定');
    //   this.formList.find(item => item.fieldName == 'customerNo').initialValue = val[0].OWNER_NO;
    //   this.formList.find(item => item.fieldName == 'customerName').initialValue = val[0].OWNER_NAME;
    //   this.visibleCustomer = false;
    // },
    handleVinSelectConfirm(val) {
      // console.log(val, '选择vin');
      this.formList.find(item => item.fieldName == 'vin').initialValue = val.carData.vin;
      this.formList.find(item => item.fieldName == 'licenseTag').initialValue = val.carData.license;
      this.formList.find(item => item.fieldName == 'model').initialValue = val.carData.model;
      this.formList.find(item => item.fieldName == 'customerNo').initialValue = val.carData.ownerNo;
      this.formList.find(item => item.fieldName == 'customerName').initialValue = val.carData.ownerName;
      this.visibleVinSelect = false;
    },
    handleCardSelectConfirm(val) {
      this.formList.find(item => item.fieldName == 'cardNo').initialValue = val.carData.vCardNo;
    },
    closeHandlerCustomer1(val, data) {
      this.visibleCustomer = false;
    },
    handleProjectConfirm(e) {},
    formChangeHandle(val) {
      this.saveData = val;
    },
    async getMaterialList(id) {
      // ajax
      const res = await getMaterialList({ id });
      if (res.resultCode === 200) {
        this.listWts = res.data.rows || [];
      }
      // this.$tableWts.STOP_LOADING();
    },
    async getProductList(id) {
      // this.$tableWts.START_LOADING();
      // ajax
      const res = await getProjectList({ id });
      if (res.resultCode === 200) {
        this.listProduct = res.data.rows || [];
      }
      // this.$tableWts.STOP_LOADING();
    },
    closeHandlerCustomer() {
      this.visibleCustomer = false;
    },
    deleteSingleService(row) {
      // 装饰项目的单个删除
      this.$refs.tableProject.$refs.pageTable.EXECUTE_DELETE([row]);
    },
    deleteMaterialSingle(row) {
      // 装饰材料的单个删除
      this.$refs.table1.$refs.pageTable.EXECUTE_DELETE([row]);
    },
    selectChange(rows) {
      // 选中时触发的函数
      console.log(rows);
      this.selectedRows = rows;
      this.isChoice = this.selectedRows.length > 0 ? false : true;
    },
    closeServiceDialog(val = false, data) {
      // 服务项目dialog关闭
      this.visibleService = false;
      console.log('closeServiceDialog', data);
      // 有新增数据
      if (data && data.length > 0) {
        data['birthday'] = this.preDateHandler(data['birthday'], 'YYYY-MM-DD');
        this.$refs.table.$refs.pageTable.EXECUTE_INSERT(data);
        // this.$refs.table.$refs.pageTable.SET_DISABLE_SELECT(data)
        console.log('closeServiceDialog', this.serviceSource);
      }
    }, // 获取派工单号数据
    async getOrderNo() {
      if (this.type == 'add') {
        this.orderData = (await getOrderNo({})).data;
        this.formList.find(item => item.fieldName == 'billNo').initialValue = this.orderData.orderNo;
        this.formList.find(item => item.fieldName == 'whManagerId').initialValue = this.orderData.userName;
      }
    },
    async saveHandler() {
      if (null == this.$refs.table1.$refs.pageTable.GET_REQUIRED_ERROR()) {
        // 保存
        this.$refs.formPanel.SUBMIT_FORM();
        for (const item of this.listWts) {
          if (item.outType == 80961002 && !item.providerName) {
            return this.$notify.warning({ title: '提示信息', message: '出库方式为一进一出的必须选择供应商!' });
          }
        }
        let params = _.cloneDeep(this.saveData);
        console.log('数据' + this.BaseTable1.dataSource);
        params.productList = _.cloneDeep(this.tableProject1.dataSource);
        params.materialList = _.cloneDeep(this.BaseTable1.dataSource);
        params.ids = this.formData.id;
        const res = await excutePartOrderInfo(params);
        if (res.resultCode == 200) {
          this.$notify.success({ title: '提示信息', message: '保存成功!' });
          this.fetchParams = { ...this.fetchParams };
          // 需要主页面刷新
          this.closeHandler('refresh');
        }
      }
    },
    // 关闭面板
    closeHandler(type) {
      this.$emit('close', false, type);
    },
    // 整车销售单选择点击确定
    handleCarOrderSelectConfirm(e) {
      console.log(e);
      this.formList.find(item => item.fieldName == 'saleOrderNo').initialValue = e.viNo;
      this.formList.find(item => item.fieldName == 'vin').initialValue = e.vin;
    }
  }
};
</script>

<style lang="less" scoped>
.wrapper {
  height: calc(100vh - 135px);
}
</style>
